using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.VisualStudio.Modeling.Validation;
using Microsoft.VisualStudio.Modeling;

namespace Evaluant.EussDSL
{
    [ValidationState(ValidationState.Enabled)]
    public partial class EussMapping : ModelElement
    {
        [ValidationMethod(ValidationCategories.Menu | ValidationCategories.Save)]
        private void UniqueTypes(ValidationContext context)
        {
            foreach (Entity entity in this.Elements)
            {
                List<Entity> le = this.Elements.FindAll(delegate(Entity entity_tmp) { return entity.type == entity_tmp.type; });
                if (le.Count > 1)
                {
                    context.LogError("Entity type '" + entity.type + "' is not unique", "001", le.ToArray());
                }
            }
        }
    }
}
